/**
 * Created by liuzeduo on 2017/8/6.
 */
(function($){
    $.sum=function(array){
        var total=0;
        $.each(array,function(index,value){
            value=  $.trim(value);
            value=parseFloat(value)||0;
            total+=value;
        });
        return total;
    };
    $.average=function(array){
        if($.isArray(array)) {
            return $.decimal(($.sum(array)/array.length),1);
        }
        return ' ';
    }// return 1 decimal by default
    $.decimal=function(float,n){
        //n how many decimals
        var pow=Math.pow(10,n);
        float=float*pow;
        return Math.round(float)/pow;
    }
})(jQuery)